import Vue from 'vue'
import VueRouter from 'vue-router'
import UserView from '../views/manage/UserView.vue'
import Layout from "@/layout/Layout.vue";
import ShopView from "@/views/shop/ShopView.vue";
import MyLayout from "@/layout/MyLayout.vue";
import ShoppingCart from "@/views/shop/ShoppingCart.vue";
import MyOrder from "@/views/shop/MyOrder.vue";
import Login from "@/views/Login.vue";
import LoginView from "@/views/LoginView.vue";
import AdviceView from "@/views/manage/AdviceView.vue";
import RefundOrderView from "@/views/manage/RefundOrderView.vue";
import AddressManage from "@/views/shop/AddressManage.vue";
import UserList from "@/views/manage/UserList.vue";
import userCarList from "@/views/user/CarList.vue";
import ShopLayout from '@/layout/ShopLayout.vue';

Vue.use(VueRouter)

const routes = [
    //   管理路由
    {
        //当一个框架有默认的子路由的时候就不需要名称，将子路由写为'/'就可以了
        path: '/home',
        component: Layout,
        // 管理子路由
        children: [
            {path: '/', alias: '/user-list', name: 'userList', component: UserList,},
            // 如果采取全局的 import 函数，就是加载的时候就会全部加载完�����这种匿名函数导入的方法就可以使用到再入
            {path: '/user-list', name: 'userList', component: () => import("@/views/manage/UserList.vue")},
            {path: '/black-list', name: 'blackList', component: () => import("@/views/manage/BlackList.vue")},
            {path: '/car-list', name: "carList", component: () => import("@/views/manage/CarList.vue")},
            {path: '/car-add', name: "carAdd", component: () => import("@/views/manage/CarAdd.vue")},
            {path: '/order-list', name: "orderList", component: () => import("@/views/manage/OrderList.vue")},
            
        ]
    },
    // 驾驶舱路由
    {
        path: '/myCharts',
        name: 'myCharts',
        component: () => import("@/views/manage/MyCharts.vue")
    },
    //   登录路由
    {
        path: '/',
        alias: '/login',
        name: 'Login',
        component: Login,
    },
    // 管理员登录路由
    {
      path: '/manageLogin',
      name: 'ManageLogin',
      component: LoginView,
    },
    //   注册路由
    {
        path: '/register',
        name: 'Register',
        component: () => import('@/views/Register.vue')
    },
    //   商城路由
  
    {
        path: '/shop',
        component: ShopLayout,
        children: [
            {
                path: '',  // 默认子路由
                redirect: 'big'
            },
            {
                path: 'big',
                name: 'UserCarList',
                component: () => import('@/views/user/Big.vue')
            },
            {
                path: 'cars-back',
                name: 'UserCarListBack',
                component: () => import('@/views/user/CarListBack.vue')
            },
            {
                path: 'cars',
                name: 'UserCarList',
                component: () => import('@/views/user/CarList.vue')
            },
            {
                path: 'car-list-back',
                name: 'UserCarListBack',
                component: () => import('@/views/user/CarListBack.vue')
            },
            {
                path: 'orders',
                name: 'UserOrderList',
                component: () => import('@/views/user/OrderList.vue')
            },
            {
                path: 'order-history',
                name: 'OrderHistory',
                component: () => import('@/views/user/OrderHistory.vue')
            },
            {
                path: 'order/create',
                name: 'OrderCreate',
                component: () => import('@/views/user/OrderCreate.vue')
            }
        ]
    },
    {path: '/*', component: () => import("@/views/404.vue")}
]

const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes
})

export default router
